import collections
class Vector2D(object):

    def __init__(self, vec):
        """
        :type vec: List[List[int]]
        """
        self.vec = collections.deque()
        for l in vec:
            for item in l:
                self.vec.append(item)
        self.index = 0


    def next(self):
        """
        :rtype: int
        """
        self.index += 1
        return self.vec[self.index - 1]

    def hasNext(self):
        """
        :rtype: bool
        """
        if self.index < len(self.vec):
            return True
        else:
            return False
